﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace ZLDC.Estate
{
                public class SessionCustomer
    {
                                        public static void Session_PublicCustomerArea_Save(int deptid)
        {
            string areas = "";

                        string parentSubDeptList = ZLDC.Topo.BLL.Estate.AuthorizationBLL.GetParentSubDeptList(ZLDC.Common.Estate._Utility.GetInfoBySession().m_sDeptID);
            if (!string.IsNullOrEmpty(parentSubDeptList))
                areas += " and ownerDeptId in (" + parentSubDeptList + ")";
            else
                areas += " and ownerDeptId in (" + ZLDC.Common.Estate._Utility.GetInfoBySession().m_sChildrenDeptList + ")";

            if (!areas.Equals(""))
                ZLDC.Common.Estate._Session.SetSession(SessionConst.SESSION_PUBLIC_CUSTOMER_AREA, areas);
        }

                                        public static string Session_PublicCustomerArea_Get(int deptid)
        {
            string areas = ZLDC.Common.Estate._Session.GetSession(SessionConst.SESSION_PUBLIC_CUSTOMER_AREA).ToString();

                        if (areas.Equals(""))
            {
                string parentSubDeptList = ZLDC.Topo.BLL.Estate.AuthorizationBLL.GetParentSubDeptList(ZLDC.Common.Estate._Utility.GetInfoBySession().m_sDeptID);
                                                                                if (!string.IsNullOrEmpty(parentSubDeptList))
                    areas = parentSubDeptList;
                else
                    areas = ZLDC.Common.Estate._Utility.GetInfoBySession().m_sChildrenDeptList;

                if (!areas.Equals(""))
                    ZLDC.Common.Estate._Session.SetSession(SessionConst.SESSION_PUBLIC_CUSTOMER_AREA, areas);
            }

            return areas;
        }

    }
}
